import React from 'react';
import { ts2Formatter,renderState,renderEnable } from 'utils';
import { actions } from 'mirrorx';
{/*
可配置化种类：

1、表格头部字段 
    1、列表页表格头部字段集合 mainTableColumn
    2、编辑页表格头部字段集合 childTableColumn

2、编辑框的字段
    1、编辑页 直接显示在页面的编辑字段 FormField
    2、编辑页 需要点击表格的增行弹框编辑的字段 FormTableField
    3. 列表页查询区域  searchField

3.表头部的按钮  headerButtonSets

4.表行尾部按钮  columnButtonSets
*/}

//表头信息

//字段属性

//基本信息
const FormDataHeader = [
    {
        enname: "code",
        zhname: "单据号",
        edit: false,
        hidepage:{0:true},
        type: "FormControl",
    },
    {
        enname: "organizationId",
        codename: "organizationCode",
        showname: "organizationName",
        zhname: "隶属组织",
        type: "RefComponent",
        edit:true,
        refname:"organization",
        required: true
    },
    {
        enname: "name",
        zhname: "活动模板名称",
        type: "FormControl",
        required: true,
        edit: true,
    },
    {
        enname: "ext01",
        zhname: "创建人",
        type: "FormControl",
        required: false,
        hidepage: { 0: true },
        edit: false,
    },
    {
        enname: "creationTime",
        zhname: "创建日期",
        type: "DatePicker",
        required: false,
        format: "YYYY-MM-DD",
        hidepage: { 0: true },
        edit: false,
    },
    {
        enname: "ext02",
        zhname: "编辑人",
        type: "FormControl",
        required: false,
        hidepage: { 0: true },
        edit: false,
    },
    {
        enname: "modifiedTime",
        zhname: "编辑日期",
        type: "DatePicker",
        format: "YYYY-MM-DD",
        required: false,
        hidepage: { 0: true },
        edit: false,
    },
];

const columnActivityPlanTemplateDetails = [
    {
        title: "活动项",
        dataIndex: "activityName",
        key: "activityId",
        renderType: "refcomponent",
        width: 250,
        required:true,
        filedProps: {
            title: "活动项",
            refName: "activityRef",
            multiple:true,
            offersparam: {
                currentkey: ["ext02"],
                offerfields: ["activityExplain"],
            },
            fieldName: "activityName",
            reffields: { refpk: "activityId", refcode: "activityCode", refname: "activityName" }
        },
    },
    {
        title: "活动项说明",
        dataIndex: "activityExplain",
        width:100,
        key: "activityExplain",
    }
]

//表单字段
export const FormField = {
    "DataHeader": {
        "title": "基础信息",
        "Field": FormDataHeader
    },
}

//表格弹框表单字段
export const FormTableField = {
}

//渲染成字表表格的头
export const childTableColumn = {
    "activityPlanTemplateDetails": {
        "title": "活动方案单模板明细",
        "type": "grid",
        "column": columnActivityPlanTemplateDetails
    },
}

//渲染成字表表格的头
export const mainTableColumn = [
    {
        title: "单据号",
        dataIndex: "code",
        width: 150,
        key: "code",
        render: (text, record) => {
            return <a style={{ "cursor": "pointer" }}
                onClick={() => {
                    actions.routing.push(
                        {
                            pathname: 'ActivityPlanTemplate-edit',
                            search: `?search_id=${record.id}&btnPageFlag=2`,
                        }
                    );
                    // location.reload();
                }}
            >
                {text}
            </a >;
        }
    },
    {
        title: "所属组织",
        dataIndex: "organizationName",
        key: "organizationName",
    },
    {
        title: "模板名称",
        width: 120,
        dataIndex: "name",
        key: "name",
    },
    {
        title: "创建人",
        width: 120,
        dataIndex: "ext01",
        key: "ext01",
    },
    {
        title: "创建日期",
        dataIndex: "creationTime",
        key: "creationTime",
        width: 120,
        render: (text) => {
            return text && ts2Formatter(text)
        }
    },
    {
        title: "修改人",
        width: 120,
        dataIndex: "ext02",
        key: "ext02",
    },
    {
        title: "修改日期",
        dataIndex: "modifiedTime",
        key: "modifiedTime",
        width: 120,
        render: (text) => {
            return text && ts2Formatter(text)
        }
    },
]
export const searchField = [
    {
        enname: "creationTime",
        zhname: "制单日期",
        required: false,
        type: "RangePicker",
        rangeField: ["creationTime", "creationTime"],
        edit: true
    },
    {
        enname: "code",
        zhname: "单据号",
        required: false,
        type: "FormControl",
        searchType:"like",
        edit: true
    },
    {
        enname: "organization",
        zhname: "所属组织",
        required: false,
        refname:"organization",
        realRef:true,
        param:{
            "AUTH_refdim": "organization", 
            "AUTH_refcod": "ExpenseSummary"
        },
        type: "RefComponent",
        edit: true
    },
]

export const headerButtonSets = [
    // {
    //     event: "ButtonAdd",
    //     zhname: "新增",
    //     color: 'primary',
    //     authcode: "9901-05-02-01",
    // }
    {
        event: "ButtonEnable",
        zhname: "启用",
        authcode: "ActivityPlanTemplatestart",
        method: "post",
        batch:true,
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-fee/fee/expense-summary/enable'
    },
    {
        event: "ButtonEnable",
        zhname: "停用",
        authcode: "ActivityPlanTemplatestop",
        method: "post",
        batch:true,
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-fee/fee/expense-summary/disenable'
    }
]

export const columnButtonSets = {
    "delete": {
        event: "ButtonDel",
        zhname: "删除",
        batch: true,
        method: "post",
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-fee/fee/activity-plan-template/deleteWithFriendly'
    },
    "edit": true,
    "detail": true
}

// export default {mainTableColumn,searchField,headerButtonSets,
//     columnButtonSets,childTableColumn,FormTableField,FormField}
export const SelectCode = ["QY132","ls002","ls001","sale","FA001","BILL_STATUS","BILL_TYPE_FEE","SALE_STATISTIC_BASIS","QRSP001","SZWD_ACTIVITYPLAN"]
